<script setup lang="ts">

import AudioPlayer from "@/Components/audioPlayer.vue";
import {onMounted, ref} from "vue";
import {sleep} from "openai/core";
import type {typeSong} from "@/store/dataType";
import {songState} from "@/store/songStore";


let ttsAudioUrl = "http://music.163.com/song/media/outer/url?id=277881.mp3"
//是否暂停播放试听
let isPauseTtsAudio = true
console.log(songState.value.currentIndex)
let audioRef = ref(null)
function addIndex(){
  songState.value.currentIndex = songState.value.currentIndex==songState.value.songList.length-1
      ? 0
      : songState.value.currentIndex+1
  console.log(songState.value.currentIndex)
}
function minusIndex(){
  songState.value.currentIndex = songState.value.currentIndex==0
      ? songState.value.songList.length-1
      : songState.value.currentIndex-1
  console.log(songState.value.currentIndex)
}

</script>

<template>

  <div class="fixed bottom-0">
    <audio-player
        class=""
        ref="audioRef"
        :audioUrl="songState.songList[songState.currentIndex].songUrl"
        :isPauseTtsAudio="true"
        :key="new Date().getTime()"
    >
    </audio-player>
  </div>
  <button @click="addIndex">下一首</button>
  <button @click="minusIndex">上一首</button>
</template>

<style scoped>

</style>